package com.gls.framework.service.core.config;

import com.gls.framework.service.core.support.CustomOauth2FeignRequestInterceptor;
import com.gls.framework.service.core.support.CustomOauth2RestTemplate;
import feign.RequestInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author lizhiyong
 */
@Configuration
@ConditionalOnMissingClass("com.netflix.zuul.ZuulFilter")
public class Oauth2ClientConfig {

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new CustomOauth2RestTemplate();
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        return new CustomOauth2FeignRequestInterceptor();
    }

}
